package com.yunxi.service.localService.impl.sat;

import com.github.pagehelper.PageInfo;
import com.yunxi.core.page.PageHelperPlus;
import com.yunxi.core.service.ServiceImplPlus;
import com.yunxi.core.util.BeanTools;
import com.yunxi.dao.sat.HandleVehicleMapper;
import com.yunxi.model.sat.HandleVehicle;
import com.yunxi.sat.pojo.HandleVehicleVO;
import com.yunxi.sat.pojo.TaskTargetVO;
import com.yunxi.service.localService.sat.HandleVehicleService;
import com.yunxi.vip.pojo.VipManageVO;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 交车信息 服务实现类
 * </p>
 *
 * @author caoYong
 * @since 2019-07-15
 */
@Service
public class HandleVehicleServiceImpl extends ServiceImplPlus<HandleVehicleMapper, HandleVehicle> implements HandleVehicleService {

    /**
     * 销售顾问月目标
     * @param taskTargetVO
     * @return
     * @throws Exception
     */
    @Override
    public TaskTargetVO taskTarget(TaskTargetVO taskTargetVO) throws Exception {
        return baseMapper.taskTarget(taskTargetVO);
    }

    /**
     * 销售经理月目标
     * @param taskTargetVO
     * @return
     * @throws Exception
     */
    @Override
    public TaskTargetVO managerTaskTarget(TaskTargetVO taskTargetVO) throws Exception {
        return baseMapper.managerTaskTarget(taskTargetVO);
    }

    @Override
    public List<HandleVehicleVO> allList(HandleVehicleVO handleVehicleVO) throws Exception {
        Map map = BeanTools.bean2map(handleVehicleVO);
        List<HandleVehicleVO> list = baseMapper.queryByList(map);
        return list;
    }

    /**
     * 根据客户编号查询客户级别
     * @param handleVehicleVO
     * @return
     * @throws Exception
     */
    @Override
    public String getCustomerLevel(HandleVehicleVO handleVehicleVO)throws Exception{
        return baseMapper.getCustomerLevel(handleVehicleVO);
    }

    @Override
    public HandleVehicleVO getInfoById(String handleId) throws Exception {
        return baseMapper.getInfoById(handleId);
    }

    @Override
    public HandleVehicleVO handleInfo(String customerNo) throws Exception {
        return baseMapper.handleInfo(customerNo);
    }

    /**
     * 查询交车专员是否存在重复时间段的交车任务
     * @param handleVehicleVO
     * @return
     */
    @Override
    public Integer queryRepeatHandle(HandleVehicleVO handleVehicleVO) {
        return baseMapper.queryRepeatHandle(handleVehicleVO);
    }

    @Override
    public HandleVehicleVO getByOrderCustomerNo(String orderCustomerNo) {
        return baseMapper.getByOrderCustomerNo(orderCustomerNo);
    }

    @Override
    public PageInfo<HandleVehicleVO> pageByVip(VipManageVO vo, Integer pageNum, Integer pageSize) {
        Map map = BeanTools.bean2map(vo);
        PageHelperPlus.startPage(pageNum,pageSize);
        List<HandleVehicleVO> list = baseMapper.pageByVip(map);
        PageInfo<HandleVehicleVO> pageInfo = new PageInfo<HandleVehicleVO>(list);
        return pageInfo;
    }

    @Override
    public HandleVehicleVO getInfoByOrderCustomerNo(String orderCustomerNo) {
        return baseMapper.getInfoByOrderCustomerNo(orderCustomerNo);
    }
}
